测试链接：https://leetcode.cn/problems/valid-triangle-number/description/
class Solution {
public:
    int triangleNumber(vector<int>& nums) {
        if(nums.size() < 3) return 0;
        int n = nums.size();
        sort(nums.begin(),nums.end());
        int left  = 0;
        int k = n - 1;
        int right = k-1;
        // cout<<nums[k];
        // cout<<nums[right];
        int sum =0;
        while(left < right && left < n && right >0)
        {
            if(nums[left] + nums[right] > nums[k])
            {
                sum += (right - left);
                k--;
                right = k-1;
            }
            else
            {
                left++;
            }
           
        }

        return sum;

    }
};